#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef short int bool;
#define true    1
#define false   0

int row = 0;
int col = 0;
int s = 0;
char intch[10];
char bits[7];
int len = 0;

int** matrix = NULL;

/*
 -1-   ---   ---
|   | |   | |   |
0   2 |   | |   |
|   | |   | |   |
 -3-   ---
|   |     | |   |
4   5     | |   |
|   |     | |   |
 -6-   ---   ---
*/
int digits[10] =
{
    1 << 6 | 1 << 5 | 1 << 4 | 0 << 3 | 1 << 2 | 1 << 1 | 1 << 0,//0
    0 << 6 | 1 << 5 | 0 << 4 | 0 << 3 | 1 << 2 | 0 << 1 | 0 << 0,//1
    1 << 6 | 0 << 5 | 1 << 4 | 1 << 3 | 1 << 2 | 1 << 1 | 0 << 0,//2
    1 << 6 | 1 << 5 | 0 << 4 | 1 << 3 | 1 << 2 | 1 << 1 | 0 << 0,//3
    0 << 6 | 1 << 5 | 0 << 4 | 1 << 3 | 1 << 2 | 0 << 1 | 1 << 0,//4
    1 << 6 | 1 << 5 | 0 << 4 | 1 << 3 | 0 << 2 | 1 << 1 | 1 << 0,//5
    1 << 6 | 1 << 5 | 1 << 4 | 1 << 3 | 0 << 2 | 1 << 1 | 1 << 0,//6
    0 << 6 | 1 << 5 | 0 << 4 | 0 << 3 | 1 << 2 | 1 << 1 | 0 << 0,//7
    1 << 6 | 1 << 5 | 1 << 4 | 1 << 3 | 1 << 2 | 1 << 1 | 1 << 0,//8
    1 << 6 | 1 << 5 | 0 << 4 | 1 << 3 | 1 << 2 | 1 << 1 | 1 << 0,//9
};


int getbits(int n, int k)
{
    return (digits[n] & (1 << k)) >> k;
}

void putbits(int nrow, int ncol, bool bvertic)
{
    int m = 0;
    if(bvertic)
    {
        for(m = nrow; m < nrow+s; m++)
            matrix[m][ncol] = '|';
    }
    else
    {
        for(m = ncol; m < ncol+s; m++)
            matrix[nrow][m] = '-';
    }
}

void putmatrix(char ch, int ncol)
{
    int i = 0;

    for(i = 0; i < 7; i++)
    {
        //printf("%d\t", getbits(ch-'0', i));
        if(getbits(ch-'0', i) == 0)
            continue;
        if(i == 0)
            putbits(1, ncol, true);
        else if(i == 1)
            putbits(0, ncol+1, false);
        else if(i == 2)
            putbits(1, ncol+s+1, true);
        else if(i == 3)
            putbits(s+1, ncol+1, false);
        else if(i == 4)
            putbits(s+2, ncol, true);
        else if(i == 5)
            putbits(s+2, ncol+s+1, true);
        else if(i == 6)
            putbits(row-1, ncol+1, false);
        else
            ;
    }
}

void showmatrix()
{
    int i = 0, j = 0;

    for(i = 0; i < row; i++)
    {
        for(j = 0; j < col; j++)
        {
            printf("%c", matrix[i][j]);
        }
        printf("\n");
    }
    printf("\n");
}

void getdigits()
{
    int i = 0;

    for(i = 0; i < len; i++)
    {
        putmatrix(intch[i], i*(s+3));
    }

}

void process()
{
    int i = 0, j = 0;

    len = strlen(intch);
    row = (2*s+3);
    col = (s+3)*len-1;



    matrix = (int**)malloc(row*sizeof(int*));
    for(i = 0; i < row; i++)
    {
        matrix[i] = (int*)malloc(col*sizeof(int));
    }
    for(i = 0; i < row; i++)
    {
        for(j = 0; j < col; j++)
        {
            matrix[i][j] = ' ';
        }
    }
    getdigits();

    showmatrix();
}

int main()
{
    //freopen("bin\\debug\\in.txt", "r", stdin);
    //freopen("bin\\debug\\out.txt", "w", stdout);
    scanf("%d %s", &s, intch);
    while(s != 0)
    {
        //printf("%s\r\n", intch);
        process();
        scanf("%d %s", &s, intch);
    }
    return 0;
}
